home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / kzr0597.zip / ARSINH.CMD < prev    next >
OS/2 REXX Batch file  |  1997-03-10  |  2KB  |  76 lines

  1. /* REXX-Programm arsinh.CMD  */
  2.  
  3.    Call RxFuncAdd 'SysLoadFuncs', RexxUtil, 'SysLoadFuncs'
  4.    Call SysLoadFuncs
  5.    Signal on syntax name arsinhMsg
  6.  
  7. /* Diese Variablen müssen für jede Prozedur definiert werden, damit die  */
  8. /* Prozedur die Variable bufND kennt und die Variable ND übernehmen kann.*/
  9.    Pfd=SysSearchPath("PATH", "kzr.cmd")
  10.    lp=LastPos("\", Pfd)
  11.    Pfd=DelStr(Pfd, 1+lp)
  12.    NDAarsinh=Pfd||"NDAarsinh.DAT"
  13.    bufND  =Pfd||"NDZahl.DAT"
  14.    bufMsg =Pfd||"Meldung.DAT"
  15.    ND = LineIn(bufND, 1)
  16.  
  17.    if ND > 400 then
  18.    do
  19.      ND=400
  20.      call charout(NDAarsinh) ; Call SysFileDelete NDAarsinh
  21.      ret=LineOut(NDAarsinh, 400)
  22.      Call Charout,"   Achtung, nur 400 Dezimalstellen bei der Berechnung von  arsinh(...)"
  23.      say
  24.      Beep(444, 200); Beep(628,300)  /* Hier kein EXIT ! */
  25.    end
  26.  
  27.    /* Wenn ND <= 400 ist, wird ND = ND  weitergegeben */
  28.    call charout(NDAarsinh) ; Call SysFileDelete NDAarsinh
  29.    ret=LineOut(NDAarsinh, ND)
  30.  
  31.    arg x,y  /* y soll "illegale" Komma's im Funktions-Argument aufspüren */
  32.    p0p=x*x  /* Diese Anweisung prvoziert eine Syntax-Fehlermeldung       */
  33.  
  34.    if length(y) > 0 then
  35.    do
  36.      call charout(NDAarsinh); Call SysFileDelete NDAarsinh
  37.      ret=LineOut(bufMsg, "Im Argument von  arsinh(...)  ist mindestens  1  nicht zulässiges Komma !")
  38.      /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  39.      /*  damit in den diesbezüglichen temporären Dateien                      */
  40.      /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  41.      EXIT
  42.    end
  43.  
  44.    Numeric Digits ND+7
  45.  
  46.    if abs(x) >  0.35 then Signal B
  47.  
  48. A: m=2; g=1; v=1; t=x*x
  49.    do forever
  50.      g=-g*t*(m-1)*(m-1)/(m*(m+1))
  51.      v=v+g
  52.      if abs(g/v) < 10**(-ND-4) then leave
  53.      m=m+2
  54.    end
  55.    y=x*v
  56.    Signal W
  57.  
  58. B: y=ln(x+sqrt(x*x+1))
  59.  
  60.    /* Ausgabe */
  61. W: numeric digits ND
  62.    return(Format(y))
  63.  
  64. arsinhMsg:
  65.    sf=ErrorText(RC)
  66.    if  Pos("Bad arithmetic conversion", sf) > 0 then
  67.    do
  68.      call charout(NDAarsinh); Call SysFileDelete NDAarsinh
  69.      ret=LineOut(bufMsg, "Sie haben in  arsinh(...)  kein gültiges Argument eingegeben !")
  70.   /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  71.   /*  damit in den diesbezüglichen temporären Dateien                      */
  72.   /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  73.      EXIT
  74.    end
  75.  
  76.